<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>添加分期购订单</title>
    <link href="/resource/admin/css/common.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="/resource/admin/js/jquery.js"></script>
    <script type="text/javascript" src="/resource/admin/js/jquery.validate.js"></script>
    <script type="text/javascript" src="/resource/admin/js/jquery.tools.js"></script>
    <script type="text/javascript" src="/resource/admin/editor/kindeditor.js"></script>
    <script type="text/javascript" src="/resource/admin/js/common.js"></script>
    <script type="text/javascript" src="/resource/admin/js/input.js"></script>
    <script type="text/javascript" src="/resource/admin/datePicker/WdatePicker.js"></script>
    <script type="text/javascript">
        $().ready(function() {
            var $inputForm = $("#inputForm");
            [@flash_message /]
            var $image1Button = $("#image1Button");
            var $image2Button = $("#image2Button");
            var $image3Button = $("#image3Button");
            var $image4Button = $("#image4Button");
            var $image5Button = $("#image5Button");
            var $image6Button = $("#image6Button");

            $image1Button.browser({basePath:"/fqg"});
            $image2Button.browser({basePath:"/fqg"});
            $image3Button.browser({basePath:"/fqg"});
            $image4Button.browser({basePath:"/fqg"});
            $image5Button.browser({basePath:"/fqg"});
            $image6Button.browser({basePath:"/fqg"});

            var contactIndex = 0;

            $("#addContact").click(function(){
                if(contactIndex>=5){
                    alert("最多添加5名联系人");
                    return
                }
                var trHtml =
                        "<tr>"+
                        "<td><input type='text' class='text' name='contactList["+ contactIndex+"].name' value=''></td>"+
                        "<td><input type='text' class='text'  name='contactList["+ contactIndex+"].mobile' value=''></td>"+
                        "<td><input type='text' class='text'  name='contactList["+ contactIndex+"].relation' value=''></td>"+
                        "<td><input type='text' class='text'  name='contactList["+ contactIndex+"].workUnit' value=''></td>"+
                        "<td>[删除]</td>"+
                        "</tr>";
                $("#contactTable").append(trHtml);
                contactIndex ++;
            });

        });
    </script>
</head>
<body>
<div class="path">
    <a href="${base}/common/index">首页</a> &raquo;添加分期购订单
</div>
<form id="inputForm" action="save" method="post" class="required-form" onsubmit="return validateForm(this)">
    <ul id="tab" class="tab">
        <li>
            <input type="button" value="基础信息" />
        </li>
        <li>
            <input type="button" value="工作信息" />
        </li>
        <li>
            <input type="button" value="联系人信息" />
        </li>
        <li>
            <input type="button" value="贷款信息" />
        </li>
        <li>
            <input type="button" value="图片" />
        </li>
    </ul>
    <table class="input tabContent">
        <tr>
            <th>
                <span class="requiredField">*</span>姓名
            </th>
            <td>
                <input type="text" name="name" class="text required" maxlength="100" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>身份证
            </th>
            <td>
                <input type="text" name="cardNo" class="text required isIdCardNo" maxlength="100" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>(起始)身份证有效期
            </th>
            <td>
                <input type="text" id="birthDate" name="cardStartDate" class="text Wdate" onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd'});" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>(截止)身份证有效期
            </th>
            <td>
                <input type="text" id="birthDate" name="cardEndDate" class="text Wdate" onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd'});" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>性别:
            </th>
            <td>
                <select name="sex" class="text required">
                    <option value="0">男</option>
                    <option value="1">女</option>
                </select>
                <input type="hidden" name="universityName" value=""/>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>出生日期
            </th>
            <td>
                <input type="text" name="birthDate" class="text Wdate" onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd'});" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>婚姻状态:
            </th>
            <td>
                <select name="marry" class="text required">
                    <option value="0">已婚</option>
                    <option value="1">未婚</option>
                    <option value="1">其他</option>
                </select>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>教育程度:
            </th>
            <td>
                <select name="eduLevel" class="text required">
                    <option value="0">高中及以下</option>
                    <option value="1">专科</option>
                    <option value="2">本科</option>
                    <option value="3">硕士及以上</option>
                </select>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>居住地址
            </th>
            <td>
                <input type="text" name="address" class="text required"  style="width: 350px;"/>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>户籍地址
            </th>
            <td>
                <input type="text" name="censusAddress" class="text required"  style="width: 350px;" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>户籍邮编
            </th>
            <td>
                <input type="text" name="censusNo" class="text required" length="6" />
            </td>
        </tr>
        <tr>
            <th>
                邮箱
            </th>
            <td>
                <input type="text" name="email" class="text email " maxlength="100" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>手机号码
            </th>
            <td>
                <input type="text" name="phone" class="text required" length="11"/>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>手机号码(备用)
            </th>
            <td>
                <input type="text" name="phoneTwo" class="text required" length="11"/>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>是否提交审批:
            </th>
            <td>
                <select name="submitStatus" class="text required">
                    <option value="0">未提交</option>
                    <option value="1">提交</option>
                </select>
            </td>
        </tr>
    </table>
    <table class="input tabContent">
        <tr>
            <th>
                <span class="requiredField">*</span>工作单位名称
            </th>
            <td>
                <input type="text" name="workUnitName" class="text required" maxlength="100" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>职业:
            </th>
            <td>
                <select name="career" class="text required">
                    <option value="0">政府及事业职员</option>
                    <option value="1">企业职员</option>
                    <option value="2">私营业主</option>
                    <option value="3">专业技术人员</option>
                    <option value="4">务农人员</option>
                    <option value="5">学生</option>
                    <option value="6">自由职业</option>
                    <option value="7">其他</option>
                </select>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>单位规模:
            </th>
            <td>
                <select name="unitSize" class="text required">
                    <option value="0">10人以下</option>
                    <option value="1">10-100人</option>
                    <option value="2">100人以上</option>
                </select>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>本单位工作年限
            </th>
            <td>
                <input type="text" name="currentUnitWorkYear" class="text number required" maxlength="100" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>总工作年限
            </th>
            <td>
                <input type="text" name="totalWorkYear" class="text number required" maxlength="100" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>职位:
            </th>
            <td>
                <select name="jobPost" class="text required">
                    <option value="0">高层管理</option>
                    <option value="1">中层管理</option>
                    <option value="2">一般管理</option>
                    <option value="3">普通职员</option>
                </select>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>任职部门
            </th>
            <td>
                <input type="text" name="jobDepartment" class="text" maxlength="100" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>单位地址
            </th>
            <td>
                <input type="text" name="unitAddress" class="text"  style="width: 350px;"/>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>单位邮编
            </th>
            <td>
                <input type="text" name="unitPostNo" class="text required" length="6" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>单位区号
            </th>
            <td>
                <input type="text" name="unitAreaCode" class="text required" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>单位电话
            </th>
            <td>
                <input type="text" name="unitPhone" class="text required" />
            </td>
        </tr>
    </table>
    <table class="input tabContent" id="contactTable">
           <tr>
               <th>
                   <span class="requiredField">*</span>关系:
               </th>
               <td>
                   <select name="contactRelation" class="text required">
                       <option value="0">父母</option>
                       <option value="1">配偶</option>
                       <option value="2">子女</option>
                       <option value="3">兄弟姐妹</option>
                   </select>
               </td>
           </tr>
           <tr>
               <th>
                   <span class="requiredField">*</span>姓名
               </th>
               <td>
                   <input type="text" name="contactName" class="text" maxlength="100" />
               </td>
           </tr>
           <tr>
               <th>
                   <span class="requiredField">*</span>手机
               </th>
               <td>
                   <input type="text" name="contactMobile" class="text" maxlength="100" />
               </td>
           </tr>
           <tr>
               <th>
                   <span class="requiredField">*</span>工作单位
               </th>
               <td>
                   <input type="text" name="contactUnit" class="text" maxlength="100" />
               </td>
           </tr>
           <tr>
               <th>
                   <span class="requiredField">*</span>地址
               </th>
               <td>
                   <input type="text" name="contactAddress" class="text" maxlength="100" />
               </td>
           </tr>
           <tr>
               <td colspan="2">&nbsp;</td>
           </tr>
           <tr>
               <th>
                   <span class="requiredField">*</span>关系:
               </th>
               <td>
                   <select name="contactRelationTwo" class="text required">
                       <option value="0">亲属</option>
                       <option value="1">同事</option>
                       <option value="2">同学</option>
                       <option value="3">朋友</option>
                       <option value="4">其他</option>
                   </select>
               </td>
           </tr>
           <tr>
               <th>
                   <span class="requiredField">*</span>姓名
               </th>
               <td>
                   <input type="text" name="contactNameTwo" class="text" maxlength="100" />
               </td>
           </tr>
           <tr>
               <th>
                   <span class="requiredField">*</span>手机
               </th>
               <td>
                   <input type="text" name="contactMobileTwo" class="text" maxlength="100" />
               </td>
           </tr>
           <tr>
               <th>
                   <span class="requiredField">*</span>工作单位
               </th>
               <td>
                   <input type="text" name="contactUnitTwo" class="text" maxlength="100" />
               </td>
           </tr>
           <tr>
               <th>
                   <span class="requiredField">*</span>地址
               </th>
               <td>
                   <input type="text" name="contactAddressTwo" class="text" maxlength="100" />
               </td>
           </tr>

    </table>
    <table class="input tabContent">
        <tr>
            <th>
                <span class="requiredField">*</span>贷款用途:
            </th>
            <td>
                <select name="loanUse" class="text required">
                    <option value="0">教育</option>
                    <option value="1">旅游</option>
                    <option value="2" selected="selected">消费</option>
                    <option value="3">其他</option>
                </select>
            </td>
        </tr>
        <tr style="display: none;" id="loanUseInfoTr">
            <th>
                贷款说明
            </th>
            <td>
                <input type="text" name="loanUseInfo" class="text" maxlength="100" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>商品金额（元）
            </th>
            <td>
                <input type="text" name="loanAmount" class="text number" maxlength="100" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>还款周期:
            </th>
            <td>
                <select name="loadMonth" class="text required">
                    <option value="12">12</option>
                    <option value="18">18</option>
                    <option value="24">24</option>
                </select>
            </td>
        </tr>
        <tr>
            <th>

            </th>
            <td>
                <span style="color: #cc0000" id="loanTip">&nbsp;</span>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>还款金额（元）
            </th>
            <td>
                <input type="text" name="loanTotal"  class="text number" maxlength="100" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>每月还款（元）
            </th>
            <td>
                <input type="text" name="loanMonPay" readonly="readonly" class="text number" maxlength="100" />
            </td>
        </tr>
    </table>
    <table class="input tabContent">
        <tr>
            <th>
                <span class="requiredField">*</span>身份证(正)
            </th>
            <td>
                <span class="fieldSet">
						<input type="text"  name="image1" class="text required"  maxlength="200">
						<input type="button" id="image1Button" class="button" value="选择文件">
                </span>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>身份证(反)
            </th>
            <td>
                <span class="fieldSet">
						<input type="text"  name="image2" class="text required"  maxlength="200">
						<input type="button" id="image2Button" class="button" value="选择文件">
                </span>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>贷款申请书(第一联)
            </th>
            <td>
                <span class="fieldSet">
						<input type="text"  name="image3" class="text required"  maxlength="200">
						<input type="button" id="image3Button" class="button" value="选择文件">
                </span>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>风险告知书
            </th>
            <td>
                <span class="fieldSet">
						<input type="text"  name="image4" class="text required"  maxlength="200">
						<input type="button" id="image4Button" class="button" value="选择文件">
					</span>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>亲签照片
            </th>
            <td>
                <span class="fieldSet">
						<input type="text"  name="image5" class="text valid"  maxlength="200">
						<input type="button" id="image5Button" class="button" value="选择文件">
					</span>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>工作/学生证明
            </th>
            <td>
                <span class="fieldSet">
						<input type="text"  name="image6" class="text required"  maxlength="200">
						<input type="button" id="image6Button" class="button" value="选择文件">
					</span>
            </td>
        </tr>
    </table>
    <table class="input">
        <tr>
            <th>
                &nbsp;
            </th>
            <td>
                <input type="submit" class="button" value="提交" />
                <input type="button" class="button" value="返回" onclick="location.href='list'" />
            </td>
        </tr>
    </table>
</form>
<script type="text/javascript">
    $(function(){
        $("select[name='loanUse']").change(function(){
            var opt=$(this).find("option:selected").val();
            if(opt==3){
                $("#loanUseInfoTr").show();
            }else{
                $("#loanUseInfoTr").hide();
            }
        });


        /** 正推算 */
        $("input[name='loanAmount'],select[name='loadMonth']").change(function(){
             var amount=$("input[name='loanAmount']").val();
             var mon=$("select[name='loadMonth']").find("option:selected").val();
             var total;
             var monPay;
             if(mon==12){
                 total=amount*1.1;
                 monPay=total/12;
             }
            if(mon==18){
                total=amount*1.14;
                monPay=total/18;
            }
            if(mon==24){
                total=amount*1.17;
                monPay=total/24;
            }
            //parseInt
            var text="总共需要偿还： ["+total+"]元,每月偿还: ["+Math.round(monPay)+"]";
            //alert(text);
            $("#loanTip").html(text);
            $("input[name='loanTotal']").val(total);
            $("input[name='loanMonPay']").val(Math.round(monPay));
        });

        /** 反推算 */
        $("input[name='loanTotal']").change(function(){
            var total=$("input[name='loanTotal']").val();
            var mon=$("select[name='loadMonth']").find("option:selected").val();
            var monPay;
            var account;
            if(mon==12){
                monPay=total/12;
                account=total/1.1
            }
            if(mon==18){
                monPay=total/18;
                account=total/1.14
            }
            if(mon==24){
                monPay=total/24;
                account=total/1.17
            }
            //parseInt
            var text="总共需要偿还： ["+total+"]元,每月偿还: ["+Math.round(monPay)+"]";
            //alert(text);
            $("#loanTip").html(text);
            $("input[name='loanAmount']").val(Math.round(account));
            $("input[name='loanTotal']").val(total);
            $("input[name='loanMonPay']").val(Math.round(monPay));
        });


    });
</script>
</body>
</html>